package ncorps.output;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Random;
import javax.swing.JFrame;
import info.monitorenter.gui.chart.Chart2D;
import info.monitorenter.gui.chart.ITrace2D;
import info.monitorenter.gui.chart.traces.Trace2DSimple;
import ncorps.commun.StatNewtonFourier;

public class ChartStatOutFrame {

    private double[][] deltapos;
    private int _N;
    private int tempsMax;

    private ChartStatOutFrame() {
        super();
    }

    public ChartStatOutFrame(StatNewtonFourier stat) {
        deltapos = stat.getDeltaposition();
        _N = stat.get_N();
        tempsMax = stat.getTempsMax();
        Chart2D chart = new Chart2D();
        ITrace2D trace = new Trace2DSimple();
        int p=50;
//        for (int p = 0; p < _N; p++) {
            for (int t = 0; t < tempsMax; t++) {
                trace.addPoint(t, deltapos[p][t]);
            }
//        }

        chart.addTrace(trace);
        JFrame frame = new JFrame("ChartStatOutFrame");
        frame.getContentPane().add(chart);
        frame.setSize(400, 300);
        frame.addWindowListener(
                new WindowAdapter() {

                    @Override
                    public void windowClosing(WindowEvent e) {
                        System.exit(0);
                    }
                });
        frame.show();
    }

//    public static void main(String[] args) {
//        // Create a chart:
//
//        // Create an ITrace:
//
//        // Add all points, as it is static:
////        Random random = new Random();
////        for (int i = 100; i >= 0; i--) {
////            trace.addPoint(i, random.nextDouble() * 10.0 + i);
////        }
//
//        // Add the trace to the chart:
//        // Make it visible:
//        // Create a frame.
//        // add the chart to the frame:
//        // Enable the termination button [cross on the upper right edge]:
//    }
}
